from Delivery_project.celery import app
from ronglian_sms_sdk import SmsSDK
from django.conf import settings


# 创建任务函数
@app.task
def send_sms(sms_code, mobile, expire=5):
    # 实例化sdk
    sdk = SmsSDK(settings.ACCID, settings.APPID, settings.AUTHTOKEN)

    # 组织数据
    tid = "1"
    mobile = "%s"%mobile
    datas = ("%s"%sms_code, "%s"%expire)

    # 发送验证码
    res = sdk.sendMessage(tid=tid, mobile=mobile, datas=datas)
    return res


